<script src="http://maps.google.com/maps/api/js?sensor=false&amp;language=id" type="text/javascript">
</script>

<script type="text/javascript">
var latitude1x = new Array();
var longitude1x = new Array();
var latitude2x = new Array();
var longitude2x = new Array();
var site_id1x = new Array();
var site_id2x = new Array();
var equipment_modelx = new Array();
var tx_freq_site1x = new Array();
var tx_freq_site2x = new Array();
// map = new google.maps.Map(document.getElementById("mapCanvas"));
var map;
function initialize() {
  var latLng = new google.maps.LatLng(<?php echo $sitelink[0]['latitude1']?>,<?php echo $sitelink[24]['longitude1']?>);
  // var map = new google.maps.Map(document.getElementById('mapCanvas'), {
    // zoom: 11,
    // center: latLng,
    // mapTypeId: google.maps.MapTypeId.ROADMAP
  // });
  var petaoption = {
        zoom: 11,
        center: latLng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
	map = new google.maps.Map(document.getElementById("mapCanvas"),petaoption);
  var j=0;
  <?php 
    $i=0;
    for($i=0;$i<sizeof($sitelink);$i++){?>
		console.log('baris: '+<?php echo $i;?>);
		latitude1x[j]=<?php echo $sitelink[$i]['latitude1']?>;
		longitude1x[j]=<?php echo $sitelink[$i]['longitude1']?>;
		latitude2x[j]=<?php echo $sitelink[$i]['latitude2']?>;
		longitude2x[j]=<?php echo $sitelink[$i]['longitude2']?>;
		site_id1x[j]="<?php echo $sitelink[$i]['site_id1']?>";
		site_id2x[j]="<?php echo $sitelink[$i]['site_id2']?>";
		tx_freq_site1x[j]="<?php echo $sitelink[$i]['tx_freq_site1']?>";
		tx_freq_site2x[j]="<?php echo $sitelink[$i]['tx_freq_site2']?>";
		equipment_modelx[j]="<?php echo $sitelink[$i]['equipment_model']?>";
		
		var marker = new google.maps.Marker({
			position: new google.maps.LatLng(<?php echo $sitelink[$i]['latitude1']?>, <?php echo $sitelink[$i]['longitude1']?>),
			title: "<?php echo $sitelink[$i]['site_id1']?>",
			map: map,
			draggable: false
		});

		var marker2 = new google.maps.Marker({
			position: new google.maps.LatLng(<?php echo $sitelink[$i]['latitude2']?>, <?php echo $sitelink[$i]['longitude2']?>),
			title: "<?php echo $sitelink[$i]['site_id2']?>",
			map: map,
			draggable: false
		});

		var garisCoordinates = [
			new google.maps.LatLng(<?php echo $sitelink[$i]['latitude1']?>, <?php echo $sitelink[$i]['longitude1']?>),
			new google.maps.LatLng(<?php echo $sitelink[$i]['latitude2']?>, <?php echo $sitelink[$i]['longitude2']?>),
		];
		var garis = new google.maps.Polyline({
		  path: garisCoordinates,
		  strokeColor: "#0000FF",
		  strokeOpacity: 0.5,
		  strokeWeight: 5,
		  message: "<b>Link ID:"+"<?php echo $sitelink[$i]['site_id1']?>"+"#"+"<?php echo $sitelink[$i]['site_id2']?></b>"+"<br><br>Tx: "+"<?php echo $sitelink[$i]['tx_freq_site1']?> MHz"+"<br>Rx: "+"<?php echo $sitelink[$i]['tx_freq_site2']?> MHz"
		});
		setinfo(marker,j);
		setinfo(marker2,j);
		garis.setMap(map);
		j++;
		//google.maps.event.addListener(garis, 'click', function() {
		var infowindow = new google.maps.InfoWindow({
		content:"hai"
		});
		google.maps.event.addListener(garis, 'click', function(event) {
			infowindow.setContent(this.message);
			infowindow.position = event.latLng;
			infowindow.open(map);
		});
	<?php } ?>
}

function setinfo(marker, nomor){
    google.maps.event.addListener(marker, 'click', function() {
		var infowindow = new google.maps.InfoWindow({
		content:"<b>Site ID: "+site_id1x[nomor]+"</b><br>Lat: "+latitude1x[nomor]+"<br>Lon: "+longitude1x[nomor]+"<br>Tx: "+tx_freq_site1x[nomor]+" MHz<br>Linked to: "+site_id2x[nomor]
		});

		//google.maps.event.addListener(tanda, 'click', function() {
		infowindow.open(map,marker);
		//});
    });
}

// Onload handler to fire off the app.

google.maps.event.addDomListener(window, 'load', initialize);
</script>


<style>
  #mapCanvas {
    width: 900px;
    height: 600px;
    float: left;
  }
</style>


<br />
<div id="mapCanvas"></div>